package io.mft.runtime.function;

import io.mft.commons.function.FunctionActionContext;
import io.mft.commons.function.response.kv.KVMap;
import io.netty.util.concurrent.FastThreadLocal;
/**
 * API接口上下文
 * @说明：TODO
 * @类型名称：ApiContext
 * @创建者: 胡常建  
 * @创建时间: 2021年1月26日 上午11:11:54
 * @修改者: 胡常建  
 * @修改时间: 2021年1月26日 上午11:11:54
 */
public class ApiContext extends FunctionActionContext<ApiFunctionRequest,ApiFunctionResponse>{
	 
	public static final FastThreadLocal<KVMap> FASTTHREADLOCAL=new FastThreadLocal<>();
	    

	public ApiContext(ApiExecutorObject apiExecutorObject,ApiFunctionRequest request,ApiFunctionResponse response) {
		super(request,response);
		this.apiExecutorObject=apiExecutorObject;
	}
	private ApiExecutorObject apiExecutorObject;
	public void setSuccessReadCache(boolean successReadCache) {
		KVMap kvMap=new KVMap();
		kvMap.set("successReadCache", successReadCache);
		FASTTHREADLOCAL.set(kvMap);
	}
	
	public boolean isSuccessReadCache() {
		KVMap kvMap=FASTTHREADLOCAL.get();
		if (kvMap==null) {
			return false;
		}else {
			boolean s=kvMap.get("successReadCache",false);
			return s;
		}
	}
	
	public void removeSuccessReadCache() {
		FASTTHREADLOCAL.remove();
	}
	public ApiExecutorObject getApiExecutorObject() {
		return apiExecutorObject;
	}
}
